//
//  Set_Root_TableViewHeaderView.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2021/12/30.
//

#import "Set_Root_TableViewHeaderView.h"
#import "UserInfoModel.h"

@interface Set_Root_TableViewHeaderView ()

@property (weak, nonatomic) IBOutlet UIView *infoView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *accountLabel;
@property (weak, nonatomic) IBOutlet UILabel *reallabel;
@property (weak, nonatomic) IBOutlet UILabel *mobileLabel;
@property (weak, nonatomic) IBOutlet UILabel *levelLabel1;
@property (weak, nonatomic) IBOutlet UILabel *levelLabel2;
@property (weak, nonatomic) IBOutlet UIImageView *sinImageView;

@property (weak, nonatomic) IBOutlet UIView *noLoginView;

@property (weak, nonatomic) IBOutlet UIImageView *userHeadImage;

@property (weak, nonatomic) IBOutlet UILabel *daijinquan;
@property (weak, nonatomic) IBOutlet UILabel *jinbi;
@property (weak, nonatomic) IBOutlet UILabel *pingtaibi;


@end

@implementation Set_Root_TableViewHeaderView

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    [self.levelLabel1 addTapBlock:^(id  _Nonnull obj) {
        if (self.headerClickClock) {
            self.headerClickClock(MineSubViewType_level1);
        }
    }];
    [self.levelLabel2 addTapBlock:^(id  _Nonnull obj) {
        if (self.headerClickClock) {
            self.headerClickClock(MineSubViewType_level2);
        }
    }];
    [self.sinImageView addTapBlock:^(id  _Nonnull obj) {
        if (self.headerClickClock) {
            self.headerClickClock(MineSubViewType_qiandao);
        }
    }];
}



- (void)reloadUI
{
    UserInfoModel *model = [LocalData fetchUserInfo];
    if (model) {
        self.infoView.hidden = NO;
        self.noLoginView.hidden = YES;
        
        [self.userHeadImage yy_setImageWithURL:[NSURL URLWithString:[LocalData getHeadStr]] placeholder:[UIImage imageNamed:@"appicon"]];
        if ([LocalData getHeadStr]) {
            UIImage *image = [NSObject Base64StrToUIImage:[LocalData getHeadStr]];
            self.userHeadImage.image = image;
        } else {
            [self.userHeadImage setImage:[UIImage imageNamed:@"appicon"]];
        }
        
        self.nameLabel.text = @"abcabcabcabc";
        self.levelLabel1.text = @"12345678";
        self.levelLabel2.text = @"7654321";
        
    } else {
        self.infoView.hidden = YES;
        self.noLoginView.hidden = NO;
        [self.userHeadImage setImage:[UIImage imageNamed:@"appicon"]];
    }
}


- (IBAction)loginClick:(id)sender {
    if (self.headerClickClock) {
        self.headerClickClock(MineSubViewType_person);
    }
}

- (IBAction)vipClick:(UIButton *)sender {
    if (self.headerClickClock) {
        self.headerClickClock(sender.tag+4);
    }
}

- (IBAction)coinClick:(UIButton *)sender {
    if (self.headerClickClock) {
        self.headerClickClock(sender.tag+5);
    }
}



@end
